﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Movies
{
    class WinDisplayControllor
    {
        private static Form mdiParant = null;

        public static Form MDIParent
        {
            set
            {
                mdiParant = value;
            }
            get
            {
                return mdiParant;
            }
        }

        public static void ShowDefaultMovieWin()
        {
            

            if (currentlyShowWin != null)
            {
                currentlyShowWin.Dispose();
            }
            if (HelperSettingProvider.Default().DefaultDisplay.Trim().Equals("0"))
            {
                ShowMovieShelve();
            }
            else
            {
                ShowMovieList();
            }
        }

        private static Form movieRakForm = null;
        private static Form currentlyShowWin = null;
        public static void ShowMovieShelve()
        {
                movieRakForm = new FormDisplayMoviesInShelve();
                movieRakForm.MdiParent = mdiParant;
                movieRakForm.WindowState = FormWindowState.Maximized;
                movieRakForm.Name = "Rak";
                currentlyShowWin = movieRakForm;
                movieRakForm.Show();                
         }


        private static Form movieListForm = null;
        public static void ShowMovieList()
        {
                movieListForm = new FormDisplayMoviesInList();
                movieListForm.MdiParent = mdiParant;
                movieListForm.WindowState = FormWindowState.Maximized;
                movieListForm.Name = "List";
                currentlyShowWin = movieListForm;
                movieListForm.Show();
        }

        public static void ApplyChangesOnLoadedWin(){
            if (currentlyShowWin == null)
            {
                return;
            }

            if (currentlyShowWin.Name.Equals("List"))
            {
                currentlyShowWin.Dispose();
                ShowMovieList();
            }
            else
            {
                currentlyShowWin.Dispose();
                ShowMovieShelve();
            }
        }


        public static Form ShowMovieDefineMovieWin()
        {
            Form childForm = new FormDefineMovieLocation();
            childForm.ShowDialog();
            return childForm;
        }


        public static void ShowChangeName()
        {
            FormNameInputWin childForm = new FormNameInputWin(true);
            childForm.Text = "Change Details";
            childForm.ShowDialog();
        }

        public static Form ShowMovieDetails()
        {
            Form movieDialog = new FormBrowserFile();
            movieDialog.ShowDialog();
            return movieDialog;
        }

        public static Form ShowDetailsDownloadWin()
        {
            Form movieDialog = new FormDownloadMovieDetails();
            movieDialog.ShowDialog();
            return movieDialog;
        }

        private static Form applyFilterForm;
        public static void ShowApplyFilterWin()
        {
            if (applyFilterForm == null)
            {
                applyFilterForm = new FormApplyFilter();
            }
            applyFilterForm.ShowDialog();
        }

        public static void DisposeApplyFilterWin()
        {
            if (applyFilterForm != null)
            {
                applyFilterForm.Dispose();
            }
            applyFilterForm = null;
            
        }

        public static void DisplayDialog(String msgText)
        {
            Form form = new FormGeneralDialog(msgText);
            form.ShowDialog();

        }

        public static void DisplayDialog(String msgText, bool isDialog)
        {
            Form form = new FormGeneralDialog(msgText);
            if (isDialog)
            {
                form.ShowDialog();
            }
            else
            {
                form.Show();
            }

        }

        public static void ShowDataStoreWin()
        {
            Form form = new FormSaveLocationOptions();
            form.ShowDialog();
        }

        private static bool showController;
        public static bool IsShownDone
        {
            get
            {
                return showController;
            }
            set
            {
                showController = value;
            }
        }
        public static void ShowQuickStart(bool force)
        {
            if (force || !HelperSettingProvider.Default().QuickStartShown.Trim().Equals("true"))
            {
                FormQuickStart form = new FormQuickStart();
                form.ShowDialog();
                HelperSettingProvider.Default().QuickStartShown = "true";
                HelperSettingProvider.Default().Save();
            }

        }

    }
}
